#include<stdio.h>
#include<stdlib.h>

#define LOG "log.txt" //日志文件
#define SIZE 32

int main()
{
    FILE* fp =fopen(LOG,"w");
    if(!fp)
    {
        perror("fopen file fail!\n");//报错
        exit(-1);//终止进程
    }
    char buffer[SIZE];//缓冲区
    int cnt = 5;
    while(cnt--)
    {
        snprintf(buffer,SIZE,"%s\n","Hello FIle!");//写入数据到缓冲区
        fputs(buffer,fp);
    }

    fclose(fp);
    fp=NULL;
    return 0;
}
